﻿@implements IDialogContentComponent<SimplePerson>

<FluentMessageBarProvider Section="@App.MESSAGES_DIALOG" MaxMessageCount="1" />

<p>Your lastname is @Content.Lastname and you are @Content.Age years young </p>

<FluentTextField @bind-Value="@Content.Firstname">Your firstname:</FluentTextField>
<FluentTextField @bind-Value="@Content.Lastname">Your lastname:</FluentTextField>
<FluentNumberField @bind-Value="@Content.Age">Your age:</FluentNumberField>

@if (Dialog != null)
{
    <FluentStack Orientation="Orientation.Vertical" Style="border: 1px solid red; padding: 10px">
        <span>This section is visible only when component is hosted inside a Dialog</span>
        <FluentButton OnClick="@(() => ToggleDialogPrimaryActionButton(true))">Enable Dialog Primary Action</FluentButton>
        <FluentButton OnClick="@(() => ToggleDialogPrimaryActionButton(false))">Disable Dialog Primary Action</FluentButton>
    </FluentStack>
}

@code {
    [Parameter]
    public SimplePerson Content { get; set; } = default!;

    [CascadingParameter]
    public FluentDialog? Dialog { get; set; }

    private void ToggleDialogPrimaryActionButton(bool enable)
    {
        Dialog!.TogglePrimaryActionButton(enable);
    }
}